--团队副本
--#include "data\functions\FuBen\TeamFuben.lua" once

--[[
enum tagTeamFubenOP
{
	gTeamFB_GetMyData		= 1,					//获取本人的团队副本数据
	gTeamFB_CreateTeam		= 2,					//创建一个团队副本的队伍
	gTeamFB_JoinTeam		= 3,					//加入一个团队副本的队伍
	gTeamFB_QuitTeam		= 4,					//退出本人所在的团队
	gTeamFB_KickMember		= 5,					//把某成员T出团队
	gTeamFB_InviteMember	= 6,					//邀请某人加入团队
	gTeamFB_BeginFuben		= 7,					//开启副本
};
]]

function GmDoTeamFB( sysarg, flag, param )
	print("GmDoTeamFB, flag="..flag..", param="..param)
	if flag == 1 then
		SendTeamFubenData( sysarg )
	elseif flag == 2 then				--查看某个副本的组队情况
		local fubenId = param
		SendFubenAllTeams( sysarg, fubenId )
	elseif flag == 3 then				--查看本人队伍数据
		SendFubenMyTeam( sysarg )
	elseif flag == 4 then				--创建团队副本
		local fubenId = param
		CreateFubenTeam( sysarg, fubenId )
	elseif flag == 5 then
		local teamId = param
		JoinFubenTeam( sysarg, teamId )
	elseif flag == 6 then				--退出本人所在队伍
		QuitFubenTeam(sysarg)
	elseif flag == 7 then				--踢出本人所在队伍
		local memberId = param
		KickFubenTeam(sysarg, memberId)
	elseif flag == 8 then				--邀请本人所在队伍
		local actorId = param
		InviteFubenTeam(sysarg, actorId)
	elseif flag == 9 then				--队长开启团队副本
		BeginTeamFuben(sysarg)
	end
end

---团队事件
TeamFubenOpFuncList = {}

EventCallDispatcher.handleTeamFubenOp = function (sysarg, args)
	--print("EventCallDispatcher.handleTeamFubenOp...")
	if args[1] == nil then return end  
	local func = TeamFubenOpFuncList[args[1]]
	if func ~= nil then
		func(sysarg, args) 
	end
end

--[[
获取本人进入团队副本的次数
]]
TeamFubenOpFuncList[gTeamFB_GetMyData] = function(sysarg,args)
	SendTeamFubenData( sysarg )
end

--[[
创建一个团队副本的队伍
]]
TeamFubenOpFuncList[gTeamFB_CreateTeam] = function(sysarg,args)
	local fubenId = args[2]
	CreateFubenTeam( sysarg, fubenId )
end


--[[
加入一个团队副本的队伍
]]
TeamFubenOpFuncList[gTeamFB_JoinTeam] = function(sysarg,args)
	local flag   = args[2]
	if flag == 1 then
		local teamId  = args[3]
		JoinFubenTeam( sysarg, teamId )				--直接接入队伍
	elseif flag == 2 then
		local fubenId = args[3]
		QuickJoinFubenTeam( sysarg, fubenId )		--快速加入副本的一个队伍
	end
end


--[[
退出本人所在的团队
]]
TeamFubenOpFuncList[gTeamFB_QuitTeam] = function(sysarg,args)
	QuitFubenTeam( sysarg )
end

--[[
把某成员T出团队
]]
TeamFubenOpFuncList[gTeamFB_KickMember] = function(sysarg,args)
	local memberId = args[2]
	KickFubenTeam( sysarg, memberId )
end

--[[
要求加入副本
]]
TeamFubenOpFuncList[gTeamFB_InviteMember] = function(sysarg,args)
	local objActorId = args[2]
	InviteFubenTeam( sysarg, objActorId )
end

--[[
开启副本
]]
TeamFubenOpFuncList[gTeamFB_BeginFuben] = function(sysarg,args)
	BeginTeamFuben( sysarg )
end

--[[
--创建团队副本
EventCallDispatcher.CreateFubenTeam = function ( sysarg, args )
	local fubenId = arg[2]
    CreateFubenTeam(sysarg, fubenId)
end

--加入团队副本
EventCallDispatcher.JoinFubenTeam = function ( sysarg, args )
	local teamId = arg[2]
    JoinFubenTeam(sysarg,teamId)
end

--系统招募
EventCallDispatcher.TeamRecruit  = function ( sysarg, args )
    TeamRecruit(sysarg,args)
end

--队长开始团队副本
EventCallDispatcher.BeginTeamFuben  = function ( sysarg, args )
    BeginTeamFuben( sysarg )
end


--被邀请参加团队副本
EventCallDispatcher.InviteeToTeam  = function ( sysarg, args )
    InviteeToTeam(sysarg,args)
end

--被T出团队副本(已经被踢出团队)
EventCallDispatcher.BeKickedTeam  = function ( sysarg, args )
	local teamId = arg[2]
    OnKickedTeam(sysarg,teamId)
end
]]

EventCallDispatcher.registerEventCall(aeTeamFubenOp, EventCallDispatcher.handleTeamFubenOp)

--[[
EventCallDispatcher.registerEventCall(aeCreateFubenTeam, EventCallDispatcher.CreateFubenTeam)
EventCallDispatcher.registerEventCall(aeJoinFubenTeam, EventCallDispatcher.JoinFubenTeam)
EventCallDispatcher.registerEventCall(aeTeamRecruit, EventCallDispatcher.TeamRecruit)
EventCallDispatcher.registerEventCall(aeBeginTeamFuben, EventCallDispatcher.BeginTeamFuben)
EventCallDispatcher.registerEventCall(aeInviteeToTeam, EventCallDispatcher.InviteeToTeam)
EventCallDispatcher.registerEventCall(aeBeKickedTeam, EventCallDispatcher.BeKickedTeam)
]]